﻿using Microsoft.Practices.Prism.UnityExtensions;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Prism.Modularity;
using System.Windows;
using Modules;
using Core.Unity;
using Core.Unity.Wpf;

namespace MeteorologicalDataCaptureTool {
    class AppBootstrapper : UnityBootstrapper {
        protected override IUnityContainer CreateContainer() {
            return base.CreateContainer();

        }

        protected override System.Windows.DependencyObject CreateShell() {
            ContainerWpf container = new ContainerWpf(this.Container);
            container.RegisterInstance<ContainerWpf>(container);

            CommandManagerWpf cmdMgr = new CommandManagerWpf();
            container.RegisterInstance<CommandManagerWpf>(cmdMgr);
             
            return this.Container.Resolve<Shell>();
        }

        protected override void InitializeShell() {
            base.InitializeShell();

            App.Current.MainWindow = (Window)this.Shell;
            App.Current.MainWindow.Show();
        }

        protected override void ConfigureModuleCatalog() {
            base.ConfigureModuleCatalog();

            ModuleCatalog mc = (ModuleCatalog)this.ModuleCatalog;
            mc.AddModule(typeof(MeteorologicalDataModule));
        }

        public override void Run(bool runWithDefaultConfiguration) {
            base.Run(runWithDefaultConfiguration); 
        }
    }
}
